﻿using EPE.DBUtility;
using EPE.IDAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace EPE.MySqlDAL
{
    public class ShopsPriceParaImpl : IShopsPricePara
    {
        public DataSet GetAllByProject(string projectid)
        {
            string strSQL;

            DataSet retDS = new DataSet();

            DataBaseTool clsDbTool = new DataBaseTool();

            try
            {
                strSQL = " SELECT paraid,projectid,parentid,paraname,paravalue,resultvalue,property,comment ";
                strSQL = strSQL + " FROM tbl_shopspricepara ";
                strSQL = strSQL + " WHERE 1=1 ";
               
                strSQL = strSQL + " AND projectid =@projectid ";



                clsDbTool.ParameterClear();
                ;
                clsDbTool.ParameterAdd("projectid", projectid);
                clsDbTool.CommandText = strSQL;
                clsDbTool.Open();

                retDS = clsDbTool.GetDataSet();

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                clsDbTool.Close();
            }
            return retDS;
        }
        public DataSet GetAllList(string projectid, string companyid)
        {
            string strSQL;

            DataSet retDS = new DataSet();

            DataBaseTool clsDbTool = new DataBaseTool();

            try
            {
                strSQL = " SELECT paraid,parentid,paraname,paravalue,resultvalue,property,comment,projectname";
                strSQL = strSQL + " FROM tbl_shopspricepara left join tbl_shopsproject on tbl_shopspricepara.projectid=tbl_shopsproject.projectid AND tbl_shopsproject.companyid=@companyid";
                strSQL = strSQL + " WHERE 1=1 ";

                if (!string.IsNullOrEmpty(projectid))
                {
                    strSQL = strSQL + " AND projectid =@projectid ";
                }
               


                clsDbTool.ParameterClear();
                
                clsDbTool.ParameterAdd("projectid", projectid);
                clsDbTool.ParameterAdd("companyid", companyid);

                clsDbTool.CommandText = strSQL;
                clsDbTool.Open();

                retDS = clsDbTool.GetDataSet();

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                clsDbTool.Close();
            }
            return retDS;
        }

    }
}
